import { _decorator, Component, Node, v3 } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('BgControl')
export class BgControl extends Component {
    start() {

    }

    update(deltaTime: number) {
        this.bgMove(deltaTime)
    }

    bgMove(dt: number) {

        let bgs = this.node.children

        for (const bg of bgs) {
            
            let {x, y} = bg.getPosition()

            y -= dt * 200

            
            if( y <= -1000) {
                y += 1000 * 2
            }
            
            bg.setPosition(v3(x, y))
            
        }

    }
}


